<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Git | 知识库</title>
    <meta name="generator" content="VuePress 1.9.9">
    <link rel="icon" href="/noteslibrary/img/favicon.ico">
    <meta name="description" content="Java后端技术博客,专注Java后端学习与总结。HTML,CSS,JavaScript,TypeScript,JavaSE,Python,Vue,React,Node,Git,Github等技术文章。">
    <meta name="keywords" content="后端博客,个人技术博客,后端,后端开发,后端框架,后端面试题,技术文档,学习,面试,HTML,CSS,JavaScript,TypeScript,JavaSE,Python,Vue,React,Node,Git,Github">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/noteslibrary/assets/css/0.styles.2500ff6d.css" as="style"><link rel="preload" href="/noteslibrary/assets/js/app.dc0c3d24.js" as="script"><link rel="preload" href="/noteslibrary/assets/js/2.a664539c.js" as="script"><link rel="preload" href="/noteslibrary/assets/js/107.256ceb5d.js" as="script"><link rel="prefetch" href="/noteslibrary/assets/js/10.bab1a8b9.js"><link rel="prefetch" href="/noteslibrary/assets/js/100.245d2d1d.js"><link rel="prefetch" href="/noteslibrary/assets/js/101.9d1c6c13.js"><link rel="prefetch" href="/noteslibrary/assets/js/102.d187686f.js"><link rel="prefetch" href="/noteslibrary/assets/js/103.b0e7acf6.js"><link rel="prefetch" href="/noteslibrary/assets/js/104.895c9e53.js"><link rel="prefetch" href="/noteslibrary/assets/js/105.235036be.js"><link rel="prefetch" href="/noteslibrary/assets/js/106.17a71ae1.js"><link rel="prefetch" href="/noteslibrary/assets/js/108.57832d85.js"><link rel="prefetch" href="/noteslibrary/assets/js/109.f8b1d1c7.js"><link rel="prefetch" href="/noteslibrary/assets/js/11.2c69801a.js"><link rel="prefetch" href="/noteslibrary/assets/js/110.f3ce6a68.js"><link rel="prefetch" href="/noteslibrary/assets/js/111.bdfd28f4.js"><link rel="prefetch" href="/noteslibrary/assets/js/112.878f599c.js"><link rel="prefetch" href="/noteslibrary/assets/js/113.0efa07cf.js"><link rel="prefetch" href="/noteslibrary/assets/js/114.c7aba251.js"><link rel="prefetch" href="/noteslibrary/assets/js/115.8b2e628d.js"><link rel="prefetch" href="/noteslibrary/assets/js/116.3392d8ba.js"><link rel="prefetch" href="/noteslibrary/assets/js/117.310538d0.js"><link rel="prefetch" href="/noteslibrary/assets/js/118.81eb015b.js"><link rel="prefetch" href="/noteslibrary/assets/js/12.e77f5a18.js"><link rel="prefetch" href="/noteslibrary/assets/js/13.d24d0054.js"><link rel="prefetch" href="/noteslibrary/assets/js/14.f29d4d33.js"><link rel="prefetch" href="/noteslibrary/assets/js/15.8694e081.js"><link rel="prefetch" href="/noteslibrary/assets/js/16.03ffb143.js"><link rel="prefetch" href="/noteslibrary/assets/js/17.83edd7b9.js"><link rel="prefetch" href="/noteslibrary/assets/js/18.58ca4447.js"><link rel="prefetch" href="/noteslibrary/assets/js/19.e136d5c2.js"><link rel="prefetch" href="/noteslibrary/assets/js/20.fd3961b6.js"><link rel="prefetch" href="/noteslibrary/assets/js/21.207406c6.js"><link rel="prefetch" href="/noteslibrary/assets/js/22.b8738ce2.js"><link rel="prefetch" href="/noteslibrary/assets/js/23.33e4529d.js"><link rel="prefetch" href="/noteslibrary/assets/js/24.ab5493c5.js"><link rel="prefetch" href="/noteslibrary/assets/js/25.2506ce48.js"><link rel="prefetch" href="/noteslibrary/assets/js/26.7e6a9c14.js"><link rel="prefetch" href="/noteslibrary/assets/js/27.e7b4e92a.js"><link rel="prefetch" href="/noteslibrary/assets/js/28.7ad46ba6.js"><link rel="prefetch" href="/noteslibrary/assets/js/29.81666f41.js"><link rel="prefetch" href="/noteslibrary/assets/js/3.8f13cd17.js"><link rel="prefetch" href="/noteslibrary/assets/js/30.07ada09b.js"><link rel="prefetch" href="/noteslibrary/assets/js/31.f271c8cf.js"><link rel="prefetch" href="/noteslibrary/assets/js/32.2350914c.js"><link rel="prefetch" href="/noteslibrary/assets/js/33.9d7bfb77.js"><link rel="prefetch" href="/noteslibrary/assets/js/34.6fcf6f6b.js"><link rel="prefetch" href="/noteslibrary/assets/js/35.0c3a88fb.js"><link rel="prefetch" href="/noteslibrary/assets/js/36.574ca92a.js"><link rel="prefetch" href="/noteslibrary/assets/js/37.72e38074.js"><link rel="prefetch" href="/noteslibrary/assets/js/38.16d408fb.js"><link rel="prefetch" href="/noteslibrary/assets/js/39.63abc4a8.js"><link rel="prefetch" href="/noteslibrary/assets/js/4.3e68fc94.js"><link rel="prefetch" href="/noteslibrary/assets/js/40.ca2bdd48.js"><link rel="prefetch" href="/noteslibrary/assets/js/41.f82c80ec.js"><link rel="prefetch" href="/noteslibrary/assets/js/42.d1b8f579.js"><link rel="prefetch" href="/noteslibrary/assets/js/43.d3fd6260.js"><link rel="prefetch" href="/noteslibrary/assets/js/44.491f9afa.js"><link rel="prefetch" href="/noteslibrary/assets/js/45.1ee0d084.js"><link rel="prefetch" href="/noteslibrary/assets/js/46.a3e0be1f.js"><link rel="prefetch" href="/noteslibrary/assets/js/47.647908d1.js"><link rel="prefetch" href="/noteslibrary/assets/js/48.9658b8b0.js"><link rel="prefetch" href="/noteslibrary/assets/js/49.8f4b8327.js"><link rel="prefetch" href="/noteslibrary/assets/js/5.a0a97ccd.js"><link rel="prefetch" href="/noteslibrary/assets/js/50.f46d1433.js"><link rel="prefetch" href="/noteslibrary/assets/js/51.f1b784a0.js"><link rel="prefetch" href="/noteslibrary/assets/js/52.cce45956.js"><link rel="prefetch" href="/noteslibrary/assets/js/53.d66dabe3.js"><link rel="prefetch" href="/noteslibrary/assets/js/54.384b864b.js"><link rel="prefetch" href="/noteslibrary/assets/js/55.47ed19f2.js"><link rel="prefetch" href="/noteslibrary/assets/js/56.193cd456.js"><link rel="prefetch" href="/noteslibrary/assets/js/57.e6ea1f8c.js"><link rel="prefetch" href="/noteslibrary/assets/js/58.97fd2330.js"><link rel="prefetch" href="/noteslibrary/assets/js/59.b0c3d9ea.js"><link rel="prefetch" href="/noteslibrary/assets/js/6.50cbd75f.js"><link rel="prefetch" href="/noteslibrary/assets/js/60.d01d0651.js"><link rel="prefetch" href="/noteslibrary/assets/js/61.385e9bae.js"><link rel="prefetch" href="/noteslibrary/assets/js/62.a93fa4c8.js"><link rel="prefetch" href="/noteslibrary/assets/js/63.f72a2142.js"><link rel="prefetch" href="/noteslibrary/assets/js/64.3bf0b024.js"><link rel="prefetch" href="/noteslibrary/assets/js/65.cb1cb3bb.js"><link rel="prefetch" href="/noteslibrary/assets/js/66.4c9ff8cd.js"><link rel="prefetch" href="/noteslibrary/assets/js/67.2fc17900.js"><link rel="prefetch" href="/noteslibrary/assets/js/68.fd3ee410.js"><link rel="prefetch" href="/noteslibrary/assets/js/69.682be05d.js"><link rel="prefetch" href="/noteslibrary/assets/js/7.80203dee.js"><link rel="prefetch" href="/noteslibrary/assets/js/70.29428a45.js"><link rel="prefetch" href="/noteslibrary/assets/js/71.aff6ef6b.js"><link rel="prefetch" href="/noteslibrary/assets/js/72.fe7572e0.js"><link rel="prefetch" href="/noteslibrary/assets/js/73.e52bc1a7.js"><link rel="prefetch" href="/noteslibrary/assets/js/74.5e72ee84.js"><link rel="prefetch" href="/noteslibrary/assets/js/75.5a5bba64.js"><link rel="prefetch" href="/noteslibrary/assets/js/76.70d6ff7c.js"><link rel="prefetch" href="/noteslibrary/assets/js/77.1db1c302.js"><link rel="prefetch" href="/noteslibrary/assets/js/78.137c92e8.js"><link rel="prefetch" href="/noteslibrary/assets/js/79.8455d34b.js"><link rel="prefetch" href="/noteslibrary/assets/js/8.9e13e493.js"><link rel="prefetch" href="/noteslibrary/assets/js/80.127f3a4e.js"><link rel="prefetch" href="/noteslibrary/assets/js/81.191d3614.js"><link rel="prefetch" href="/noteslibrary/assets/js/82.6ae31745.js"><link rel="prefetch" href="/noteslibrary/assets/js/83.640cd3d7.js"><link rel="prefetch" href="/noteslibrary/assets/js/84.22c036e2.js"><link rel="prefetch" href="/noteslibrary/assets/js/85.692cd496.js"><link rel="prefetch" href="/noteslibrary/assets/js/86.793e38a7.js"><link rel="prefetch" href="/noteslibrary/assets/js/87.eb27f1d6.js"><link rel="prefetch" href="/noteslibrary/assets/js/88.6d48c75e.js"><link rel="prefetch" href="/noteslibrary/assets/js/89.a798bacb.js"><link rel="prefetch" href="/noteslibrary/assets/js/9.7e864ff7.js"><link rel="prefetch" href="/noteslibrary/assets/js/90.e814aadc.js"><link rel="prefetch" href="/noteslibrary/assets/js/91.5c132772.js"><link rel="prefetch" href="/noteslibrary/assets/js/92.d0d1984d.js"><link rel="prefetch" href="/noteslibrary/assets/js/93.bbc81ca6.js"><link rel="prefetch" href="/noteslibrary/assets/js/94.242fbc29.js"><link rel="prefetch" href="/noteslibrary/assets/js/95.f7232d68.js"><link rel="prefetch" href="/noteslibrary/assets/js/96.440e6bbe.js"><link rel="prefetch" href="/noteslibrary/assets/js/97.a8ad3aa8.js"><link rel="prefetch" href="/noteslibrary/assets/js/98.e9a01f98.js"><link rel="prefetch" href="/noteslibrary/assets/js/99.e024f354.js">
    <link rel="stylesheet" href="/noteslibrary/assets/css/0.styles.2500ff6d.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/noteslibrary/" class="home-link router-link-active"><img src="/noteslibrary/img/EB-logo.png" alt="知识库" class="logo"> <span class="site-name can-hide">知识库</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/noteslibrary/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="基础" class="dropdown-title"><a href="/noteslibrary/basis/" class="link-title">基础</a> <span class="title" style="display:none;">基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《计算机网络》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《计算机组成原理》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《操作系统》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《数据结构》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《算法》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《设计模式》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/noteslibrary/fontend/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/0796ba76b4b55368.html" class="nav-link">《JS笔记》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/f344d070a1031ef7.html" class="nav-link">《ES6笔记》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/note/vue/" class="nav-link">《Vue笔记》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/noteslibrary/backend/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>JavaEE框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/d0b17d/" class="nav-link">《DAO全家桶》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/a9ac80/" class="nav-link">《Spring全家桶》</a></li></ul></li><li class="dropdown-item"><h4>BigData框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Hadoop生态》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Spark生态》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Flink生态》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><a href="/noteslibrary/database/" class="link-title">数据库</a> <span class="title" style="display:none;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/32e9fd/" class="nav-link">MySQL</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="工具" class="dropdown-title"><a href="/noteslibrary/tools/" class="link-title">工具</a> <span class="title" style="display:none;">工具</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/3ac065/" class="nav-link">Maven</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Git</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="收藏" class="dropdown-title"><a href="/noteslibrary/collect/" class="link-title">收藏</a> <span class="title" style="display:none;">收藏</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/50c072/" class="nav-link">博客收藏</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其他" class="dropdown-title"><a href="/noteslibrary/others/" class="link-title">其他</a> <span class="title" style="display:none;">其他</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>博客部署</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/db737d/" class="nav-link">Hexo</a></li></ul></li><li class="dropdown-item"><h4>系统安装</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/3ac066/" class="nav-link">系统安装</a></li></ul></li><li class="dropdown-item"><h4>idea快捷键</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/111c73/" class="nav-link">idea快捷键</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/noteslibrary/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/noteslibrary/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/noteslibrary/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/noteslibrary/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/lcfqzd/vuepress-theme-vdoing" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/noteslibrary/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="基础" class="dropdown-title"><a href="/noteslibrary/basis/" class="link-title">基础</a> <span class="title" style="display:none;">基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《计算机网络》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《计算机组成原理》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《操作系统》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《数据结构》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《算法》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/9a7ee40fc232253e/" class="nav-link">《设计模式》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端" class="dropdown-title"><a href="/noteslibrary/fontend/" class="link-title">前端</a> <span class="title" style="display:none;">前端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>笔记</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/0796ba76b4b55368.html" class="nav-link">《JS笔记》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/f344d070a1031ef7.html" class="nav-link">《ES6笔记》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/note/vue/" class="nav-link">《Vue笔记》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="后端" class="dropdown-title"><a href="/noteslibrary/backend/" class="link-title">后端</a> <span class="title" style="display:none;">后端</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>JavaEE框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/d0b17d/" class="nav-link">《DAO全家桶》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/a9ac80/" class="nav-link">《Spring全家桶》</a></li></ul></li><li class="dropdown-item"><h4>BigData框架</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Hadoop生态》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Spark生态》</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/404" class="nav-link">《Flink生态》</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><a href="/noteslibrary/database/" class="link-title">数据库</a> <span class="title" style="display:none;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/32e9fd/" class="nav-link">MySQL</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="工具" class="dropdown-title"><a href="/noteslibrary/tools/" class="link-title">工具</a> <span class="title" style="display:none;">工具</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/3ac065/" class="nav-link">Maven</a></li><li class="dropdown-subitem"><a href="/noteslibrary/pages/5760de/" aria-current="page" class="nav-link router-link-exact-active router-link-active">Git</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="收藏" class="dropdown-title"><a href="/noteslibrary/collect/" class="link-title">收藏</a> <span class="title" style="display:none;">收藏</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4></h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/50c072/" class="nav-link">博客收藏</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其他" class="dropdown-title"><a href="/noteslibrary/others/" class="link-title">其他</a> <span class="title" style="display:none;">其他</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>博客部署</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/db737d/" class="nav-link">Hexo</a></li></ul></li><li class="dropdown-item"><h4>系统安装</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/3ac066/" class="nav-link">系统安装</a></li></ul></li><li class="dropdown-item"><h4>idea快捷键</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/noteslibrary/pages/111c73/" class="nav-link">idea快捷键</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/noteslibrary/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/noteslibrary/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/noteslibrary/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/noteslibrary/archives/" class="nav-link">归档</a></li></ul></div></div> <a href="https://github.com/lcfqzd/vuepress-theme-vdoing" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>常用工具</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/noteslibrary/pages/3ac065/" class="sidebar-link">Maven</a></li><li><a href="/noteslibrary/pages/5760de/" aria-current="page" class="active sidebar-link">Git</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#一、git简介" class="sidebar-link">一、Git简介</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#二、git下载及安装" class="sidebar-link">二、Git下载及安装</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#三、git架构" class="sidebar-link">三、Git架构</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#四、git基本使用" class="sidebar-link">四、Git基本使用</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#五、远程仓库" class="sidebar-link">五、远程仓库</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#六、远程仓库操作" class="sidebar-link">六、远程仓库操作</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#七、分支管理" class="sidebar-link">七、分支管理</a></li><li class="sidebar-sub-header level2"><a href="/noteslibrary/pages/5760de/#八、idea整合git使用" class="sidebar-link">八、Idea整合Git使用</a></li></ul></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/noteslibrary/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><a href="/noteslibrary/tools/#工具" data-v-06225672>工具</a></li><li data-v-06225672><a href="/noteslibrary/tools/#常用工具" data-v-06225672>常用工具</a></li></ul> <div class="info" data-v-06225672><!----> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2023-04-05</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">Git<!----></h1> <!----> <div class="theme-vdoing-content content__default"><h2 id="一、git简介"><a href="#一、git简介" class="header-anchor">#</a> 一、Git简介</h2> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638203.png" alt="image-20220307174642114"></p> <h4 id="_1-1-项目的版本管理"><a href="#_1-1-项目的版本管理" class="header-anchor">#</a> 1.1 项目的版本管理</h4> <blockquote><p>在项目开发过程中，项目每开发到一个节点就会对当前项目进行备份，这个备份就是项目的一个版本；当我们继续开发一个阶段后，再次进行备份，就生成新的版本——多个版本的集合就是项目的版本库</p></blockquote> <p>在项目版本管理中，我们可以使用手动进行管理，但是存在一些问题：</p> <ul><li>需要手动维护版本的更新日志，记录每个版本的变化</li> <li>需要手动查找历史版本，当历史版本比较多的时候，查找工作很繁琐</li> <li>当我们需要回退到某个版本时，只能够手动的通过IDE工具手动打开</li></ul> <h4 id="_1-2-团队协同开发"><a href="#_1-2-团队协同开发" class="header-anchor">#</a> 1.2 团队协同开发</h4> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638205.png" alt="1616032657017"></p> <h4 id="_1-3-版本管理工具-git"><a href="#_1-3-版本管理工具-git" class="header-anchor">#</a> 1.3 版本管理工具—Git</h4> <blockquote><p>Git是一个开源的分布式版本控制系统，用于敏捷高效的处理任何大小项目的版本管理</p></blockquote> <p>核心功能：</p> <ul><li>项目的版本管理</li> <li>团队协同开发</li></ul> <h2 id="二、git下载及安装"><a href="#二、git下载及安装" class="header-anchor">#</a> 二、Git下载及安装</h2> <h4 id="_2-1-下载git"><a href="#_2-1-下载git" class="header-anchor">#</a> 2.1 下载Git</h4> <table><thead><tr><th>https://git-scm.com/</th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638206.png" alt="1616033012417"></td></tr></tbody></table> <h4 id="_2-2-安装git"><a href="#_2-2-安装git" class="header-anchor">#</a> 2.2 安装Git</h4> <blockquote><p>除了选择安装位置以外，其他都傻瓜式安装</p></blockquote> <h4 id="_2-3-检查"><a href="#_2-3-检查" class="header-anchor">#</a> 2.3 检查</h4> <ul><li><code>win + r</code></li> <li>输入<code>cmd</code></li> <li>输入 <code>git --version</code></li></ul> <h2 id="三、git架构"><a href="#三、git架构" class="header-anchor">#</a> 三、Git架构</h2> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638207.png" alt="1616034871080"></p> <h2 id="四、git基本使用"><a href="#四、git基本使用" class="header-anchor">#</a> 四、Git基本使用</h2> <h4 id="_4-1-创建版本库"><a href="#_4-1-创建版本库" class="header-anchor">#</a> 4.1 创建版本库</h4> <ul><li><p>在工作空间的目录中，右键“<code>Git Bash Here</code>”打开<code>git</code>终端</p></li> <li><p>在Git终端中输入<code>git init</code>指令，创建版本库（就是一个<code>.git</code>目录）</p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638208.png" alt="1616036472274"></p></li></ul> <h4 id="_4-2-查看版本库状态"><a href="#_4-2-查看版本库状态" class="header-anchor">#</a> 4.2 查看版本库状态</h4> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> status
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="_4-3-将工作空间的修改添加到暂存区"><a href="#_4-3-将工作空间的修改添加到暂存区" class="header-anchor">#</a> 4.3 将工作空间的修改添加到暂存区</h4> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> <span class="token function">add</span> a.txt   <span class="token comment">## 只将工作空间中的某个文件add到暂存区</span>
<span class="token function">git</span> <span class="token function">add</span> <span class="token builtin class-name">.</span>       <span class="token comment">## 将工作空间中所有文件都add暂存区</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="_4-4-将暂存区内容提交到版本库-仓库"><a href="#_4-4-将暂存区内容提交到版本库-仓库" class="header-anchor">#</a> 4.4 将暂存区内容提交到版本库（仓库）</h4> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">'版本说明'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="_4-5-查看版本库中的历史版本"><a href="#_4-5-查看版本库中的历史版本" class="header-anchor">#</a> 4.5 查看版本库中的历史版本</h4> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> log <span class="token parameter variable">--oneline</span>  <span class="token comment">## 每个版本信息只显示一行</span>
get log            <span class="token comment">## 显示每个版本的详细信息</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="_4-6-设置用户信息"><a href="#_4-6-设置用户信息" class="header-anchor">#</a> 4.6 设置用户信息</h4> <blockquote><p>因为我们将暂存区的内容提交到版本时，会记录当前版本的提交的用户信息，因此在版本提交之前需要先绑定用户信息</p></blockquote> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> config <span class="token parameter variable">--global</span> user.name <span class="token string">'ergou'</span>
<span class="token function">git</span> config <span class="token parameter variable">--global</span> user.email <span class="token string">'haha@hehe.com'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="_4-7-同步历史版本到工作空间"><a href="#_4-7-同步历史版本到工作空间" class="header-anchor">#</a> 4.7 同步历史版本到工作空间</h4> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> checkout 版本号
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="五、远程仓库"><a href="#五、远程仓库" class="header-anchor">#</a> 五、远程仓库</h2> <h4 id="_5-1-远程仓库"><a href="#_5-1-远程仓库" class="header-anchor">#</a> 5.1 远程仓库</h4> <blockquote><p>远程仓库，远程版本库；实现版本库的远程存储，以实现团队的协同开发</p></blockquote> <table><thead><tr><th>远程仓库</th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638209.png" alt="1616038980419"></td></tr></tbody></table> <h4 id="_5-2-如何获得远程仓库"><a href="#_5-2-如何获得远程仓库" class="header-anchor">#</a> 5.2 如何获得远程仓库</h4> <ul><li>使用GitLab搭建私服</li> <li>远程仓库提供商
<ul><li>GitHub  https://gitbub.com</li> <li>Gitee（码云） https://gitee.com</li> <li>Coding</li></ul></li></ul> <h4 id="_5-3-创建远程仓库-码云"><a href="#_5-3-创建远程仓库-码云" class="header-anchor">#</a> 5.3 创建远程仓库（码云）</h4> <ul><li><p>注册账号</p> <ul><li>366274379  / admin123</li></ul> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638210.png" alt="1616039783023"></p></li> <li><p>创建远程仓库：https://gitee.com/qfytao/j2010.git</p></li> <li><p>远程仓库管理（添加开发人员）</p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638211.png" alt="1616040201202"></p></li></ul> <h2 id="六、远程仓库操作"><a href="#六、远程仓库操作" class="header-anchor">#</a> 六、远程仓库操作</h2> <h4 id="_6-1-push本地仓库到远程仓库"><a href="#_6-1-push本地仓库到远程仓库" class="header-anchor">#</a> 6.1 push本地仓库到远程仓库</h4> <h6 id="_6-1-1-准备工作"><a href="#_6-1-1-准备工作" class="header-anchor">#</a> 6.1.1 准备工作</h6> <ol><li><p>创建本地工作空间</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token class-name">D</span><span class="token operator">:</span>\fmwy
	src
		main
			java
			resources
		test
			java
	pom<span class="token punctuation">.</span>xml
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></li> <li><p>初始化本地仓库</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> init
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>将工作空间搭建的项目结构add到暂存区</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> <span class="token function">add</span> <span class="token builtin class-name">.</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>将暂存区文件提交到版本库，生成第一个版本</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">'创建项目'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>为当前项目创建一个远程仓库</p> <p><code>https://gitee.com/qfytao/fmwy.git</code></p></li></ol> <h6 id="_6-1-2-本地仓库关联远程仓库"><a href="#_6-1-2-本地仓库关联远程仓库" class="header-anchor">#</a> 6.1.2 本地仓库关联远程仓库</h6> <blockquote><p>建立<code>D:\fmwy</code>中的本地仓库 和 远程仓库<code>https://gitee.com/qfytao/fmwy.git</code>的关联</p></blockquote> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> remote <span class="token function">add</span> origin https://gitee.com/qfytao/fmwy.git <span class="token comment">#关联远程仓库并取别名origin</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_6-1-3-查看远程仓库状态"><a href="#_6-1-3-查看远程仓库状态" class="header-anchor">#</a> 6.1.3 查看远程仓库状态</h6> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> remote <span class="token parameter variable">-v</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_6-1-4-将本地仓库push到远程仓库"><a href="#_6-1-4-将本地仓库push到远程仓库" class="header-anchor">#</a> 6.1.4 将本地仓库push到远程仓库</h6> <blockquote><p>push到远程仓库需要gitee的帐号和密码</p></blockquote> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> push origin master
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638212.png" alt="1616049675765"></p> <h4 id="_6-2-其他开发者pull远程仓库到本地"><a href="#_6-2-其他开发者pull远程仓库到本地" class="header-anchor">#</a> 6.2 其他开发者pull远程仓库到本地</h4> <blockquote><p>其他开发者：<code>www.1114325587@qq.com</code></p></blockquote> <h6 id="_6-2-1-先创建本地仓库"><a href="#_6-2-1-先创建本地仓库" class="header-anchor">#</a> 6.2.1 先创建本地仓库</h6> <ul><li><p>在<code>E</code>盘创建<code>ws</code>目录(<strong>空目录</strong>)，进入<code>ws</code>目录，打开<code>Git</code>客户端</p></li> <li><p>创建本地版本库(<strong>必须的，才能拉取</strong>)</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> init
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul> <h6 id="_6-2-2-拉取远程仓库到本地"><a href="#_6-2-2-拉取远程仓库到本地" class="header-anchor">#</a> 6.2.2 拉取远程仓库到本地</h6> <ul><li><p>拉取远程仓库</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> pull 远程仓库地址 master
<span class="token function">git</span> pull https://gitee.com/qfytao/fmwy2.git master
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li></ul> <h4 id="_6-3-解决协同开发冲突问题"><a href="#_6-3-解决协同开发冲突问题" class="header-anchor">#</a> 6.3 解决协同开发冲突问题</h4> <div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token title important"><span class="token punctuation">#</span> 场景:    Helloworld.java  [bbb]</span>

<span class="token code keyword">    开发者1：涛哥                              开发者2：小乔</span>
<span class="token hr punctuation">-------------------------------------------------------------------------------------------</span>
    git pull fmwy2 master                    git pull fmwy2 master							
									         在Hellworld.java中新增内容 “bbb”
    在Hellworld.java中新增内容 “aaa”
									         git add .
									         git commit -m ''
									         git push fmwy2 master
    git add .
    git commit -m ''
    git push fmwy2 master【会失败！！！----在我pull之后，push之前被其他开发人员push过】
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token title important"><span class="token punctuation">#</span> 问题：我该如何操作？</span>
    git pull fmwy2 master 【将小乔修改的内容拉取到我本地】

<span class="token code keyword">    对文件进行冲突合并</span>

<span class="token code keyword">    git add .
	git commit -m ''
	git push fmwy2 maste</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>HelloWorld.java</p> <div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token blockquote punctuation">&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</span>HEAD
<span class="token title important">aaa
<span class="token punctuation">=================</span></span>
bbb
&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; sikdfhjkasdfhjasdfhjk
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><blockquote><p><code>一般是多人同时修改就会出现冲突问题</code></p> <p>解决：<strong>修改之前先pull一下</strong></p></blockquote> <h2 id="七、分支管理"><a href="#七、分支管理" class="header-anchor">#</a> 七、分支管理</h2> <h4 id="_7-1-什么是分支"><a href="#_7-1-什么是分支" class="header-anchor">#</a> 7.1 什么是分支</h4> <blockquote><p>分支就是版本库中记录版本位置（支线），分支之间项目会影响，使用分支可以对项目起到保护作用</p> <p>分支就是一条时间线，每次提交就在这条时间线上形成一个版本</p></blockquote> <h4 id="_7-2-分支特性"><a href="#_7-2-分支特性" class="header-anchor">#</a> 7.2 分支特性</h4> <ul><li>创建一个新的版本库，默认创建一个主分支—<code>master</code>分支</li> <li>每个分支可以进行单独管理（常规分支、保护分支、只读分支）</li> <li>分支是可以合并的</li></ul> <h4 id="_7-3-分支操作"><a href="#_7-3-分支操作" class="header-anchor">#</a> 7.3 分支操作</h4> <h6 id="_7-3-1-创建分支"><a href="#_7-3-1-创建分支" class="header-anchor">#</a> 7.3.1 创建分支</h6> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> branch branch_name
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_7-3-2-查看分支"><a href="#_7-3-2-查看分支" class="header-anchor">#</a> 7.3.2 查看分支</h6> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> branch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_7-3-3-切换分支"><a href="#_7-3-3-切换分支" class="header-anchor">#</a> 7.3.3 切换分支</h6> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> branch branch_name  <span class="token comment"># 切换到指定分支上的最新版本</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_7-3-4-检出分支"><a href="#_7-3-4-检出分支" class="header-anchor">#</a> 7.3.4 检出分支</h6> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token function">git</span> checkout 历史版本 <span class="token parameter variable">-b</span> branch_name  <span class="token comment"># 签出指定的历史版本创建新分支</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h6 id="_7-3-5-分支合并"><a href="#_7-3-5-分支合并" class="header-anchor">#</a> 7.3.5 分支合并</h6> <ul><li>三方合并</li> <li>快速合并</li></ul> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 在master分支执行 git merge dev   表示将dev分支合并merge</span>
<span class="token function">git</span> merge breanch_name
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638213.png" alt=""></p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token comment"># 查看版本倒状树</span>
<span class="token function">git</span> log <span class="token parameter variable">--online</span> <span class="token parameter variable">--graph</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h6 id="_7-3-6、企业分支模型"><a href="#_7-3-6、企业分支模型" class="header-anchor">#</a> 7.3.6、企业分支模型</h6> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638214.png" alt="image-20220309004332675"></p> <h2 id="八、idea整合git使用"><a href="#八、idea整合git使用" class="header-anchor">#</a> 八、Idea整合Git使用</h2> <blockquote><p>作为<code>Java</code>开发工程，我们代码的编写工作都是在<code>IDE</code>工具<code>idea</code>中完成，因此我们需要了解和掌握直接使用<code>IDE</code>工具完成<code>Git</code>的操作</p></blockquote> <h4 id="_8-1-idea关联git"><a href="#_8-1-idea关联git" class="header-anchor">#</a> 8.1 IDEA关联Git</h4> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638215.png" alt="1616118889055"></p> <h4 id="_8-2-idea中git版本管理"><a href="#_8-2-idea中git版本管理" class="header-anchor">#</a> 8.2 IDEA中Git版本管理</h4> <blockquote><p>准备工作：打开<code>IDEA</code>新建一个<code>web</code>工程</p></blockquote> <h6 id="_8-2-1-创建本地版本库"><a href="#_8-2-1-创建本地版本库" class="header-anchor">#</a> 8.2.1 创建本地版本库</h6> <table><thead><tr><th></th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638216.png" alt="1616119511804"></td></tr> <tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638217.png" alt="1616119549533"></td></tr></tbody></table> <h6 id="_8-2-2-设置忽略文件"><a href="#_8-2-2-设置忽略文件" class="header-anchor">#</a> 8.2.2 设置忽略文件</h6> <blockquote><p>在工作空间中有些文件是不需要记录到版本库中的（例如<code>.idea</code>、<code>target</code>、<code>.iml</code>文件），可以通过设置忽略提交来实现</p></blockquote> <ul><li><p>在工作空间的根目录（项目的根目录）中创建一个名为<code>.gitignore</code>文件</p></li> <li><p>在<code>.gitignore</code>文件配置忽略过滤条件</p> <div class="language-markdown line-numbers-mode"><pre class="language-markdown"><code><span class="token title important"><span class="token punctuation">#</span> Compiled class file</span>
<span class="token italic"><span class="token punctuation">*</span><span class="token content">.class
# Log file
</span><span class="token punctuation">*</span></span>.log
<span class="token title important"><span class="token punctuation">#</span> BlueJ files</span>
<span class="token italic"><span class="token punctuation">*</span><span class="token content">.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
</span><span class="token punctuation">*</span></span>.jar
<span class="token italic"><span class="token punctuation">*</span><span class="token content">.war
</span><span class="token punctuation">*</span></span>.nar
<span class="token italic"><span class="token punctuation">*</span><span class="token content">.ear
</span><span class="token punctuation">*</span></span>.zip
<span class="token italic"><span class="token punctuation">*</span><span class="token content">.tar.gz
</span><span class="token punctuation">*</span></span>.rar
<span class="token title important"><span class="token punctuation">#</span> virtual  machine  crash  logs,  see</span>
http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid<span class="token italic"><span class="token punctuation">*</span><span class="token content">
.classpath
.project
.settings
target
.idea
</span><span class="token punctuation">*</span></span>.iml
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div></li></ul> <h6 id="_8-2-3-将工作空间add到暂存区"><a href="#_8-2-3-将工作空间add到暂存区" class="header-anchor">#</a> 8.2.3 将工作空间add到暂存区</h6> <ul><li><p>选择项目/文件---右键---<code>Git</code>---<code>Add</code>（<code>添加到暂存区的文件</code>--<code>绿色</code>）</p></li> <li><p>如果一个文件创建好之后还没有添加到暂存区--棕红色</p></li> <li><p>添加到暂存区的操作可以设置默认添加</p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638218.png" alt="1616120607480"></p></li></ul> <h6 id="_8-2-4-将暂存区提交到版本库"><a href="#_8-2-4-将暂存区提交到版本库" class="header-anchor">#</a> 8.2.4 将暂存区提交到版本库</h6> <ul><li><p>选择项目/文件---右键---<code>Git</code>---<code>Commit</code>（<code>记录到版本库的文件</code>--<code>黑色</code>）</p></li> <li><p>如果对记录到版本库的文件进行了修改，也就是说工作空间和版本库不一致--蓝色</p></li></ul> <h4 id="_8-3-idea中git分支管理"><a href="#_8-3-idea中git分支管理" class="header-anchor">#</a> 8.3 IDEA中Git分支管理</h4> <h6 id="_8-3-1-创建分支"><a href="#_8-3-1-创建分支" class="header-anchor">#</a> 8.3.1 创建分支</h6> <ul><li>点击IDEA右下角<code>Git</code></li> <li>在弹窗中点击<code>New Branch</code></li> <li>输入新分支的名称</li></ul> <h6 id="_8-3-2-切换分支"><a href="#_8-3-2-切换分支" class="header-anchor">#</a> 8.3.2 切换分支</h6> <ul><li>点击IDEA右下角<code>Git</code></li> <li>点击非当前分支右边的箭头</li> <li>在选项卡点击<code>checkout</code></li></ul> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638219.png" alt="image-20220309012108110"></p> <h6 id="_8-3-3-删除分支"><a href="#_8-3-3-删除分支" class="header-anchor">#</a> 8.3.3 删除分支</h6> <table><thead><tr><th>点击右小角git</th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638220.png" alt="1616123528818"></td></tr></tbody></table> <h6 id="_8-3-4-合并分支"><a href="#_8-3-4-合并分支" class="header-anchor">#</a> 8.3.4 合并分支</h6> <blockquote><p>例如：将<code>dev</code>合并到<code>master</code></p></blockquote> <ul><li>切换到<code>master</code>分支</li> <li>点击<code>dev</code>分支右面的箭头，在展开的菜单中选择<code>Merge into current</code></li></ul> <h4 id="_8-4-idea中使用git进行团队协同开发"><a href="#_8-4-idea中使用git进行团队协同开发" class="header-anchor">#</a> 8.4 IDEA中使用Git进行团队协同开发</h4> <h6 id="_8-4-1-项目管理者"><a href="#_8-4-1-项目管理者" class="header-anchor">#</a> 8.4.1 项目管理者</h6> <ol><li><p>完成项目搭建</p> <ul><li>略</li></ul></li> <li><p>为当前项目创建本地版本库</p></li> <li><p>将搭建好的项目提交到本地版本库</p> <ul><li><code>add</code>到暂存区</li> <li><code>commit</code>到版本库</li></ul></li> <li><p>创建远程版本库（远程仓库）</p> <ul><li><code>https://gitee.com/qfytao/git-jd.git</code></li> <li>管理—添加开发者</li></ul></li> <li><p>将本地仓库<code>push</code>到远程仓库（<code>master</code>分支——<code>master</code>分支）</p></li></ol> <table><thead><tr><th><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638221.png" alt="1616124645208"></th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638222.png" alt="1616124765710"></td></tr> <tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638223.png" alt="1616124999737"></td></tr></tbody></table> <ol start="6"><li><p>在本地创建dev分支</p> <blockquote><p>在远程仓库<code>checkout as</code> 新建本地<code>dev</code>分支（<code>master</code>需要进行保护）</p></blockquote> <table><thead><tr><th><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638224.png" alt="1616125230163"></th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638225.png" alt="1616125375770"></td></tr></tbody></table></li> <li><p>将本地<code>dev</code>分支<code>push</code>到远程仓库，新建远程仓库的<code>dev</code>分支</p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638226.png" alt="1616125529083"></p></li> <li><p>设置远程仓库中<code>master</code>分支为保护分支</p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638227.png" alt="1616125664648"></p></li></ol> <h6 id="_8-4-2-项目开发者"><a href="#_8-4-2-项目开发者" class="header-anchor">#</a> 8.4.2 项目开发者</h6> <ol><li><p>从管理员提供的远程仓库<code>pull</code>项目到本地</p> <ul><li>远程仓库 <code>https://gitee.com/qfytao/git-jd.git</code></li></ul> <table><thead><tr><th><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638228.png" alt="1616126055257"></th></tr></thead> <tbody><tr><td><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638229.png" alt="1616126193999"></td></tr></tbody></table></li> <li><p>打开项目（此时本地工作空间的项目和远程仓库是同步的）</p></li> <li><p>开发步骤：</p> <ul><li>选择要修改的文件--<code>pull</code></li> <li>进行修改操作</li> <li>测试本地修改</li> <li><code>add</code>到暂存区</li> <li><code>commit</code>到本地版本库</li> <li><code>push</code>到远程仓库（<code>dev</code>）</li></ul></li></ol> <h4 id="_8-5-解决团队协同开发的冲突问题"><a href="#_8-5-解决团队协同开发的冲突问题" class="header-anchor">#</a> 8.5 解决团队协同开发的冲突问题</h4> <blockquote><p>冲突：在<code>pull</code>之后，<code>push</code>之前被其他开发者<code>push</code>成功</p></blockquote> <ul><li>选择产生冲突的文件---<code>pull</code></li> <li>弹出弹窗提示：<code>accpet yours</code> | <code>accept theirs</code> | <code>Merge</code> <ul><li><code>accpet yours</code>  保留自己的版本（提交时会覆盖其他开发者代码）</li> <li><code>accpet theirs</code> 保留远程仓库上的版本（会导致自己修改的代码丢失）</li> <li><strong>Merge</strong> 手动合并（和其他开发者沟通合并方案）</li></ul></li></ul> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638230.png" alt="image-20220309123407883"></p> <p><img src="https://lcfimgsbed.oss-cn-chengdu.aliyuncs.com/img/202203311638231.png" alt="image-20220309123423552"></p></div></div> <!----> <div class="page-edit"><div class="edit-link"><a href="https://github.com/lcfqzd/vuepress-theme-vdoing/edit/master/docs/97.工具/01.常用工具/02.Git.md" target="_blank" rel="noopener noreferrer">编辑</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="tags"><a href="/noteslibrary/tags/?tag=Git" title="标签">#Git</a></div> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/noteslibrary/pages/3ac065/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">Maven</div></a> <!----></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/noteslibrary/pages/3ac065/" class="prev">Maven</a></span> <!----></p></div></div></div> <!----></main></div> <div class="footer"><!----> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2018-2023
    <span>LCFQZD | MIT License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/noteslibrary/assets/js/app.dc0c3d24.js" defer></script><script src="/noteslibrary/assets/js/2.a664539c.js" defer></script><script src="/noteslibrary/assets/js/107.256ceb5d.js" defer></script>
  </body>
</html>
